#include "GameControl.h"
#include "../GameLogic/ICell.h"
#include "Grid.h"
#include "cocos2d.h"
#include "Strategy.h"

CGameControl* CGameControl::s_gameControl = NULL;

CGameControl* CGameControl::sharedGameControl()
{
	if (!s_gameControl)
	{
		s_gameControl = new CGameControl();
	}
	return s_gameControl;
}

/*int testInt = 0;
bool CGameControl::OnSelected(CCPoint p)
{

	CGrid* grid = (CGrid*)GetGrid();
	CCTMXLayer *layer = grid->GetCCTMXLayer();
	//if (layer->tileAt(p) == NULL)
	//{

	//if (testInt++ % 2 == 0)
	//{
	//	// remove already exist tile
	//	for (int i = 0; i < layer->getLayerSize().width; i++)
	//		for (int j = 0; j < layer->getLayerSize().height; j++)
	//		{
	//			CCPoint point = CCPointMake(i, j);
	//			if (layer->tileGIDAt(point) == 2)
	//				layer->removeTileAt(point);
	//		}
	//	layer->setTileGID(2, p);
	//}
	//else
	//	layer->setTileGID(3, p);
	//}
	return true;
}*/
void CGameControl::init(IGrid* grid, IStrategy* strategy, IGameConfig config)
{
	IGameControl::init(grid, strategy, config);
	m_participators[0].type = 2;
	m_participators[1].type = 3;
}

//void CGameControl::SetCell(CCPoint p, int type)
//{
//	m_grid->ReplaceCell(p, CellFactory::sharedCellFactory()->GetCell(type));
//}
void CGameControl::ApplyAiPlay()
{
}
void CGameControl::OnSwitchNextPlayer()
{
}